﻿/// ****************************************************************************
/// Author:	        Robin Zhu
/// Create Date:	2012-4-17
/// Purpose: 		用户会话集合
/// ****************************************************************************
/// Modify By		Date			Remark
/// Robin           2013-1-24       修改Remove方法定义
/// ****************************************************************************
/// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RB.Domain.RelationalMapping;
using RB.DataAccess;

namespace RB.Web.Security.Rdb
{
    public class UserSessionSet : KeyedRecordSet<UserSession, string>
    {
        public override bool Contains(UserSession item)
        {
            return this.Any(p => p.Ticket == item.Ticket);
        }

        public override bool Remove(UserSession item, Executor exec)
        {
            return this.RemoveAll(p => p.Ticket == item.Ticket, exec) > 0;
        }

        public override UserSession this[string key]
        {
            get
            {
                return this.AsQueryable().Where(p => p.Ticket == key).SingleOrDefault();
            }
            set
            {
                Update(p => value, p => p.Ticket == key);
            }
        }
    }
}
